<?php
# ***** BEGIN LICENSE BLOCK *****
# This file is part of "myWiWall".
# Copyright (c) 2007-2008 CRP Henri Tudor and contributors.
# All rights reserved.
#
# "myWiWall" is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
# 
# "myWiWall" is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with "myWiWall"; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# ***** END LICENSE BLOCK *****

?>
<h1><?php echo __("Users Management"); ?></h1>

<form id="add_user" class="add_form" method="get" action="../../index.php/adminUsers/add">
	<fieldset>
		<legend><?php echo __("Create a new user"); ?></legend>
		<p class="submit">
		<input class="button" id="create_user" type="submit" value="<?php echo __("Create"); ?>"/>
		</p>
	</fieldset>
</form>

<h2><?php echo __("Portal users"); ?></h2>

<?php foreach ($users as $user): ?>

	<div class="item <?php echo (($i++) % 2 == 0) ? 'even' : 'odd' ?>">
		<div class="name">
			<?php echo $user['username']; ?>
		</div>
		<div class="control">
			<a href="../../index.php/adminUsers/edit?userId=<?php echo $user['id']; ?>" class="editOption control" title="<?php echo sprintf(__("Modify user '%s'"), $user['username']); ?>"><img src="../../views/<?php echo $GLOBALS['dir_theme'] ?>img/admin-users-edit.png" alt="<?php echo sprintf(__("Modify user '%s'"), $user['username']); ?>" class="controlImage"/></a>
			<a href="#" id="d_<?php echo str_replace('.','_',$user['username']); ?>" class="deleteOption control" title="<?php echo sprintf(__("Delete user '%s'"), $user['username']); ?>"><img src="../../views/<?php echo $GLOBALS['dir_theme'] ?>img/admin-users-delete.png" alt="<?php echo __("Delete user '%s'"); ?>" class="controlImage"/></a>
		</div>
	</div>
	
	<div id="deleteContainer_<?php echo str_replace('.','_',$user['username']); ?>" class="delete container" style="display: none;">
		<form class="form_container" action="../../index.php/adminUsers/deleteAction" method="post">
			<div class="edit_message"><?php printf(__("Are you sure you want to delete the '%s' user ?"), htmlspecialchars($user['username'])); ?></div>
			
			<input name="userId" type="hidden" value="<?php echo $user['id']; ?>"/>
			<input class="button" type="submit" value="<?php echo __('Delete'); ?>"/>
			<input class="button" type="reset" value="<?php echo __('Cancel'); ?>"/>
		</form>
	</div>
	
<?php endforeach; ?>